package wsi.gui.function.select;

import java.awt.Dimension;
import java.awt.event.KeyEvent;

import org.rygh.gui.swing.button.SButton;
import org.rygh.gui.swing.button.SCancelButton;
import org.rygh.gui.swing.button.SOkCloseButton;
import org.rygh.gui.swing.presenter.SwingPresenter;
import org.rygh.gui.swing.tree.STreeView;
import org.rygh.gui.swing.view.one.SOneTreeView;
import org.rygh.gui.swing.window.SwingWindow;

@SuppressWarnings("serial")
public class FunctionSelectWindow extends SwingWindow implements
		FunctionSelectPresenter.Display {

	private final SOneTreeView view = new SOneTreeView();
	private final SwingPresenter presenter;

	public FunctionSelectWindow(SwingPresenter presenter) {
		super("Select Function");

		this.presenter = presenter;

		layoutComponents();
		center();
	}

	@Override
	public STreeView getTree() {
		return view.getTree();
	}

	private void layoutComponents() {
		STreeView tree = view.getTree();

		view.setPreferredSize(new Dimension(480, 360));
		addCenterView(view);
		addTopView(tree.getFilterField().getLongView());

		addButton(new SCancelButton(this));
		addButton(new SOkCloseButton(presenter));
		addButton(new SButton("Refresh", KeyEvent.VK_R, presenter, "refresh"));
		addButton(tree.getExpandAllButton());
		addButton(tree.getCollapseAllButton());

		pack();
	}

}
